
/*---------begin changed by wangwei--------------*/
//the whole file is changed, the original file is named as pi_inlet_old.c
/*---------end changed---------------------------*/


/* $Header: pi_inlet.c,v 2.2 01/10/02 10:27:58 przybyls Exp $ */

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991                 */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME:                                                        */
/* ============                                                        */
/*                                                                     */
/* Author:                                                             */
/*                                                                     */
/* MODULE PURPOSE:                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/***********************************************************************/


/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/

#include <typedefs.h>
#include <p_wkfile.h>
#include <wkfile.h>
#include <i_op.h>
#include <p_status.h>
#include <pcb_defs.h>
#include <list_mgmt.h>
#include <ramps.h>         /* needed for status.h */
#include <zone_config.h>   /* needed for status.h */
#include <zone_status.h>   /* needed for status.h */
#include <status.h>     /* definition of Oven_Table */
#include <math.h>
#include <error.h>       /* needed for zone_ui.h */
#include <zone_ui.h>     /* to get time <--millisec conversions */
#include <oven.h>        /* to get DetermineInletZoneConfig proto */
#include <exception.h>   /* to use SetException */
#include <err_handler.h> /* to use SetException */
#include <glp.h>
#include <clock_ui.h>
#include <keyboard.h>
#include <run_ui.h>

/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/

#include "proto.h"
#include "p_tcomp.h"

/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/

#define MAX(x,y) (((x)>(y))?(x):(y))
#define MIN(x,y) (((x)<(y))?(x):(y))


/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/


/*****************************/
/*   LOCAL DEFINES           */
/*****************************/

#define OLD_MISER_MODE 0

#define SCALING_SCALE_FACTOR    0x100

/*****************************/
/*   STATIC VARIABLES        */
/*****************************/


/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/
/**begin_proto**/

BIT8 EpcInletChk ( pINLET_STATUS status2 )

/**end_proto**/
{

    if (( status2->Config->Type == PP     )   ||
        ( status2->Config->Type == SS     )   ||
        ( status2->Config->Type == COC    )   ||
        ( status2->Config->Type == JIB    )   ||
        ( status2->Config->Type == ACI    )   ||
        ( status2->Config->Type == SIMDIST)   ||
        ( status2->Config->Type == VOLATILES) ||
        ( status2->Config->Type == PTV    )   ||
        ( status2->Config->Type == CIS4   )   ||
        ( status2->Config->Type == CIS3   )    )
    {
        return TRUE;
    }
    else
    {
        return FALSE;
    }
}

/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 EpcInlet ( pINLET_STATUS status )

/**end_proto**/
{

    if ( !status->Config->Functional ) return FALSE; /* dead inlet */
    if ( EpcInletChk(status) )
    {
        return TRUE ;
    }
    else
    {
        return FALSE ;
    }
}
/***********************************************************************/
/* FUNCTION:                                                           */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:                                                            */
/*                                                                     */
/*     this routine is special to avoid deadlocks when powering        */
/*     on in recovery mode.  we could have a case where the flow       */
/*     system is in const pres mode, such that a now cool oven         */
/*     has caused a flow sensor to cap.  This should NOT keep          */
/*     the oven in hold off.  I know this is ugly, but there does      */
/*     not seem to be a better way.                                    */
/*                                                                     */
/* RETURNED VALUE:                                                     */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/***********************************************************************/
/**begin_proto**/

BIT8 OkToReleaseOvenHoldOff ( pINLET_STATUS status )

/**end_proto**/
{

   if ((( status->Config->Type == PP )          ||
        ( status->Config->Type == SS )          ||
        ( status->Config->Type == ACI)          ||
        ( status->Config->Type == SIMDIST)      ||
        ( status->Config->Type == PTV)          ||
        ( status->Config->Type == CIS4)         ||
        ( status->Config->Type == VOLATILES)    ||
        ( status->Config->Type == CIS3  )  ) &&
        ( status->Ready.Flow.Reported_Ready == FALSE ) &&
        ( status->Ready.Flow.Controlled ) &&
        ( status->Ready.Flow.In_Bounds  ) &&
        ( status->Ready.Flow.Capped     ))
   {
       return TRUE;
   }
   else
   {
       return FALSE;
   }

}

